from typing import List
from alg import Solution
from gen import generate_test_cases

def is_beautiful(arr: List[int]) -> bool:
    """
    验证数组是否是漂亮数组
    :param arr: 待验证的数组
    :return: 是否是漂亮数组
    """
    n = len(arr)
    # 检查是否是1到n的排列
    if sorted(arr) != list(range(1, n + 1)):
        return False
    # 检查是否满足漂亮数组的条件
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(i + 1, j):
                if 2 * arr[k] == arr[i] + arr[j]:
                    return False
    return True

def run_tests():
    """
    运行测试用例
    """
    solution = Solution()
    test_cases = generate_test_cases()
    
    print("开始测试：")
    for i, n in enumerate(test_cases, 1):
        result = solution.beautifulArray(n)
        is_valid = is_beautiful(result)
        print(f"\n测试用例 {i}:")
        print(f"n = {n}")
        print(f"生成的数组: {result}")
        print(f"是否满足漂亮数组条件: {is_valid}")

if __name__ == "__main__":
    run_tests() 